<?php include("header.php") ?>
<!--  start page-heading -->
<div id="page-heading">
<h1>All users</h1>
</div>
<!-- end page-heading -->

<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
<tr>
<th rowspan="3" class="sized"><img src="images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
<th class="topleft"></th>
<td id="tbl-border-top">&nbsp;</td>
<th class="topright"></th>
<th rowspan="3" class="sized"><img src="images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
</tr>
<tr>
<td id="tbl-border-left"></td>
<td>
<!--  start content-table-inner ...................................................................... START -->
<div id="content-table-inner">

<!--  start table-content  -->
<div id="table-content">

<!--  start product-table ..................................................................................... -->
<form id="mainform" action="">
<?php

// Connect to server and select databse.
mysql_connect(DBADDR, DBUSER, DBPWD)or die("cannot connect");
mysql_select_db(DBNAME)or die("cannot select DB");
mysql_query('set names utf8'); 

if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };
if (isset($_GET["sort"])) { $order_col  = $_GET["sort"]; } else { $order_col='nom'; };

if ($page<0 || ((int)$page != $page)) {
	$message  = 'Invalid page number: ' .$page . "\n";
	die($message);
}

$start_from = ($page>0) ? ($page-1) * 15 : 0;
$sql = "SELECT `id` `email`, `sex`, `nom`, `prenom`, `tel`, `zip` FROM `user_info` ORDER BY $order_col ASC LIMIT $start_from, 15";
$rs_result = mysql_query ($sql);

$rs_count_result = mysql_query ("SELECT COUNT('id') FROM user_info");
$total_records = mysql_fetch_row($rs_count_result);
$total_pages = ceil($total_records[0] / 15);
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$rs_result) {
	$message  = 'Invalid query: ' . mysql_error() . "\n";
	$message .= 'Whole query: ' . $sql;
	die($message);
}
?> 
<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
<tr>
<th class="table-header-repeat line-left minwidth-10"><a href="" <?php if(isset($order) && $order!=""){if($order=="asc"){echo "style='background: url(images/table/table_sort_arrow.gif) right no-repeat;'";}else{echo "style='background: url(images/table/table_sort_arrow_up.gif) right no-repeat;'";}} ?>>Nom</a>	</th>
<th class="table-header-repeat line-left minwidth-10"><a href="">Prenom</a></th>
<th class="table-header-repeat line-left"><a href="">E-mail</a></th>
<th class="table-header-options line-left"><a href="">Options</a></th>
</tr>
<?php
while ($row = mysql_fetch_assoc($rs_result)) { 
	?>
	<tr>
	<td><?php echo $row['nom']; ?></td>
	<td><?php echo $row['prenom']; ?></td>
	<td><?php echo $row["email"]; ?></td>

	<td class="options-width">
	<a href="javascript:void(0);" title="Edit" class="icon-1 info-tooltip"></a>
	<a href="javascript:void(0);" title="Delete" class="icon-2 info-tooltip"></a>
	</td>
	</tr>
	<?php
};
?> 
</table>
<!--  end product-table................................... --> 
</form>
</div>
<!--  end content-table  -->


<!--  start paging..................................................... -->
<table border="0" cellpadding="0" cellspacing="0" id="paging-table">
<tr>
<td>
<a href="allusers.php?page=1" class="page-far-left"></a>
<a <?php if(($page-1)>=1) echo "href=\"allusers.php?page=".($page-1)."\"" ?> class="page-left"></a>
<div id="page-info">Page <strong><?=$page?></strong> / <?=$total_pages?></div>
<a <?php if(($page+1)<=$total_pages) echo "href=\"allusers.php?page=".($page+1)."\"" ?> class="page-right"></a>
<a href="allusers.php?page=<?=$total_pages?>" class="page-far-right"></a>
</td>
<td>
</td>
</tr>
</table>
<!--  end paging................ -->

<div class="clear"></div>

</div>
<!--  end content-table-inner ............................................END  -->
</td>
<td id="tbl-border-right"></td>
</tr>
<tr>
<th class="sized bottomleft"></th>
<td id="tbl-border-bottom">&nbsp;</td>
<th class="sized bottomright"></th>
</tr>
</table>
<div class="clear">&nbsp;</div>

</div>
<!--  end content -->
<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer........................................................END -->

<div class="clear">&nbsp;</div>

<!-- start footer -->         
<div id="footer">
<!--  start footer-left -->
<div id="footer-left">

Admin Skin &copy; Copyright Internet Dreams Ltd. <span id="spanYear"></span> <a href="">www.netdreams.co.uk</a>. All rights reserved.</div>
<!--  end footer-left -->
<div class="clear">&nbsp;</div>
</div>
<!-- end footer -->

</body>
</html>